import React, { PureComponent } from 'react'

function Loadable(Com) {
    return class extends PureComponent {
        state = {
            Template: null
        }
        async componentDidMount() {
            let module = await Com()
            this.setState({
                Template: module.default
            })
        }
        render() {
            const { Template } = this.state
            {
                return(
                    Template ? <Template {...this.props} /> : null
                )
            }
        }
    }
}

export default Loadable
